
/*******************
 * 主要实现的具体填充方法  点击分页也是调这个接口
 * 全局调用的方法就是queryPage 固定参数个数及方法名
 * @param pagenum 页码
 * @param pageinfo 顶部分页区域的id
 * @param panalid 需要填充的id 
 */
function queryPage(pagenum,pageinfo,panalid,type){
	if(type!=0 && type!=undefined){
		itemType = type;
		var title = "正在征集";
		if(itemType==2){
			title = "过期征集";
		}
		$("#titleinfo").html(title);
	}
	var keyword = $("#keyword").val();
	if(pagenum>countPage){
		pagenum = countPage;
	}
	queryParam.keyword = keyword;
	queryParam.curPage = pagenum;//设置需要重新查询的页码
	queryParam.itemType = itemType;
	
	$("#"+panalid).html("<img src='images/ajaxLoader.gif'/>");
	draftService.findDraft(queryParam,function(data){
		countPage = data.totalPage;
		var list = eval(data.list);
		var htm = "没有任何数据";
		var css = 2;
		
		if(list.length>0){
			htm = "";
			for(var i=0;i<list.length;i++){
				var d = list[i];
				if(i%2!=0){
					css = 3;
				}else{
					css = 2;
				}
				var url = "itemList.html?id="+d.ID+" target=_blank";
				if(itemType==2){
					url = d.PUBDOC;
				}
				htm += "<ul class='canzj_table'>"+
					        "<li class='canzj_name"+css+"'><a href="+url+">"+d.TITLENAME+"</a> </li>"+
					        "<li class='canzj_day"+css+"'>"+d.START_TIME+"至"+d.END_TIME+"</li>"+
					        "<li class='canzj_p"+css+"'>"+d.VNUM+"</li>"+
				        "</ul>";
			}
		}
		
		$("#"+panalid).html(htm);
		setPage(pagenum,pageinfo,panalid); 
	});
}


$(document).ready(function(){  
	initPageFile();  
    
	indexService.getUserBean(function(data){
		  UserBean = data;
		  if(UserBean.roleID!='5' && UserBean.roleID!='9'){//管理用户只能访问管理页面
			  window.location = "caoanAdminList.html";
		  }
		  if(UserBean.roleID!='5'){
			  $("#topuser").html("您好！"+UserBean.username+
				"<span style='width:10px; padding:0 10px;'>|</span><a href='LogoutServerServlet'>[退出]</a>");
		  }else{
			  $("#topuser").html("您还没有登录 <span style='width:10px; padding:0 10px;'>|</span><a href='"+UserBean.serverLogin+"'>[登录]</a>");
		  }
		  
		  queryPage(1,"pageinfo","itemlist",1);
	});
    
});